package com.dog.basics.admin.controller.mtkj;


import com.dog.basics.bean.dto.admin.mtkj.WheelchairAddDto;
import com.dog.basics.bean.dto.admin.mtkj.WheelchairEditDto;
import com.dog.basics.bean.dto.admin.mtkj.WheelchairFromDto;
import com.dog.basics.bean.vo.admin.mtkj.WheelchairVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.IPageVo;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceWheelchairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * <p>
 * 设备轮椅 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-29
 */
@RestController
@RequestMapping("/pc/device/wheelchair")
@Api(value = "设备轮椅模块", tags = "设备轮椅模块")
@AllArgsConstructor
public class MtDeviceWheelchairController {
    private final IMtDeviceWheelchairService mtDeviceWheelchairService;

    /**
     * @Description: 设备轮椅列表
     * @Param: WheelchairFromDto
     * @return: IPage<WheelchairVo>
     * @Author: wph
     * @Date:
     */

    @ApiOperation(value = "设备轮椅列表", notes = "pc:mtDeviceWheelchair:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceWheelchair:page')")
    public R<IPageVo<WheelchairVo>> page(PageParam page, WheelchairFromDto obj) {
        IPageVo<WheelchairVo> list = mtDeviceWheelchairService.getPageList(page, obj);
        return R.ok(list);
    }

    /**
     * @Description: 增加设备轮椅
     * @Param: WheelchairAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加设备轮椅")
    @ApiOperation(value = "增加设备轮椅", notes = "pc:mtDeviceWheelchair:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceWheelchair:save')")
    public R<Boolean> save(@Valid @RequestBody WheelchairAddDto obj) {
        return R.ok(mtDeviceWheelchairService.saveObj(obj));
    }

    /**
     * @Description: 删除设备轮椅
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除设备轮椅")
    @ApiOperation(value = "删除设备轮椅", notes = "pc:mtDeviceWheelchair:delete")
    @ApiImplicitParam(value = "设备轮椅Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceWheelchair:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceWheelchairService.deleteObj(id));
    }

    /**
     * @Description: 修改设备轮椅
     * @Param: WheelchairEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改设备轮椅")
    @ApiOperation(value = "修改设备轮椅", notes = "pc:mtDeviceWheelchair:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceWheelchair:edit')")
    public R<Boolean> edit(@Valid @RequestBody WheelchairEditDto obj) {
        return R.ok(mtDeviceWheelchairService.editObj(obj));
    }
    /**
     * @Description: 开启关闭设备
     * @Param: WheelchairEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("开启关闭设备")
    @ApiOperation(value = "开启关闭设备", notes = "pc:mtDeviceWheelchair:editUse")
    @PutMapping("/editUse/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceWheelchair:editUse')")
    @ApiImplicitParam(value = "设备轮椅Id", name = "id", dataType = "Long", required = true)
    public R<Boolean> editUse(@PathVariable("id") Long id) {
        return R.ok(mtDeviceWheelchairService.editUse(id));
    }
}
